package com.itheima.filter;


import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import java.io.IOException;
//注解方式配置
//@WebFilter("/*")
@WebFilter(value="/*",initParams={
        @WebInitParam(name="encoding",value="gbk"),
        @WebInitParam(name="age",value="22")
})
public class FilterDemo1 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init...");
        String encoding = filterConfig.getInitParameter("encoding");
        String age = filterConfig.getInitParameter("age");
        System.out.println(encoding+"==="+age);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("=================");
        chain.doFilter(request,response);
        System.out.println("我回来了");
    }

    @Override
    public void destroy() {
        System.out.println("destory...");
    }
}
